<template>
    <div>
        <!-- 键盘事件 按键修饰符 .13和.enter都表示回车的键码 -->
        <input @keyup.13="append(name)" v-model="name" type="text" />
        <!-- 展示面板 -->
        <ul>
            <li v-for="(value,index) in list" :key="index"> 
                {{value}}
            </li>
        </ul>

    </div>
</template>
<script>
export default {
    methods:{
        append(name){
            if(name.trim().lenght){
                this.list.push(name)
                this.name = ''
            }else{
                alert("值不许为空")
            }
            //擦产检来的数据push到数组里
            
        }
    },
    data(){
        return {
            list:[]
        }
    }
}
</script>